package com.tianji.remark.controller;


import com.tianji.remark.domain.dto.LikeRecordFormDTO;
import com.tianji.remark.service.ILikedRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 点赞记录表 前端控制器
 * </p>
 *
 * @author 东哥
 * @since 2025-10-28
 */
@Api(tags = "点赞业务相关接口")
@RestController
@RequestMapping("/likes")
@RequiredArgsConstructor
public class LikedRecordController {
    private final ILikedRecordService likedRecordService;

    /**
     * 1、点赞或取消点赞（Day6- 课堂1）
     *
     * @param formDTO
     */
    @PostMapping
    @ApiOperation("点赞或取消点赞")
    public void likeOrUnlike(@RequestBody LikeRecordFormDTO formDTO) {
        likedRecordService.likeOrUnlike(formDTO);
    }

    /**
     * 2、根据业务ID集合查询点赞状态（Day6- 课堂2）
     */
    @GetMapping("list")   // localhost:8091/likes/list?bizIds=1,2,3
    @ApiOperation("根据业务ID集合查询点赞状态")
    public Set<Long> isLiked(@RequestParam("bizIds") List<Long> bizIds) {
        return likedRecordService.isLiked(bizIds);
    }
}
